package tut.Struct.Struct;

import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Vector;

public class EnumerationTest {
	public static void main(String args[]) {
		Enumeration days;
		Vector dayNames = new Vector();
		dayNames.add("Sunday");
		dayNames.add("Monday");
		dayNames.add("Tuesday");
		dayNames.add("Wednesday");
		dayNames.add("Thursday");
		dayNames.add("Friday");
		dayNames.add("Saturday");
		days = dayNames.elements();
		while (days.hasMoreElements()) {
			System.out.println(days.nextElement());
		}

		List<Integer> ll1 = new LinkedList<Integer>();  //(1)オブジェクトの生成

	    for (int i = 0; i < 10; i++) {
	      ll1.add(new Integer(i));  //(2)要素を追加
	    }

	    //(3)後方への順次アクセス
	    for (Iterator<Integer> i = ll1.iterator(); i.hasNext();) {
	      System.out.println("後方処理" + i.next());
	    }

	    //(4)前方への順次アクセス
	    ListIterator<Integer> i = ll1.listIterator(ll1.size());
	    while(i.hasPrevious()) {
	      System.out.println("前方処理" + i.previous());
	    }

	}
}
